package cn.stacey.day08;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.junit.Test;


public class TraversalMap {
//	private int[] ROOM= {202,203,605,421};
//	private String[] NAME= {"袁大头","吕小弟","夏雨荷","陈哈哈"};
	@Test
	public void testtraversalMap() {
		Map<Integer,String> map=new HashMap<>();
		map.put(202, "袁大头");
		map.put(203,"吕小弟");
		map.put(421,"陈哈哈");
//		map.entrySet();
//		System.out.println(map.entrySet());
		Set<Entry<Integer,String>> entrySet=map.entrySet();
		//遍历map集合
		//迭代器模式遍历
		Iterator<Entry<Integer,String>> iterator=entrySet.iterator();
		while(iterator.hasNext()) {
			Entry<Integer,String> entry=iterator.next();
			System.out.println(entry.getValue()+"\t"+entry.getKey());
		}
		//for循环遍历
		for(Entry<Integer,String> entry:entrySet) {
			System.out.println(entry);
		}

		
		//map.keySet()取所有的key
		System.out.println(map.keySet());
		//map.values()取value
		System.out.println(map.values());
		String[] students = {"james", "jack", "jane"};
		double[] mathScores = {88, 99.5, 60};
		double[] chineseScores = {60, 50.5, 60};
		Map<String,List<Double>> map1=new HashMap<>();
		List<Double> scores=new ArrayList<>();
		scores.add(mathScores[0]);
		scores.add(chineseScores[0]);
		map1.put(students[0], scores);
//		System.out.println(map1.put(students[0], scores));
		

		List<Double> scores1=new ArrayList<>();
		scores1.add(mathScores[1]);
		scores1.add(chineseScores[1]);
		map1.put(students[1], scores1);
//		System.out.println(map1.put(students[1], scores1));
		
		List<Double> scores2=new ArrayList<>();
		scores2.add(mathScores[2]);
		scores2.add(chineseScores[2]);
		map1.put(students[2], scores2);
		
		List<Double> list=map1.get("jane");
		System.out.println(list);
		
		
		
		
		
		
		
		
	}
	
		
	
	
}
